package com.bwie.controller;
import com.bwie.pojo.Recourd;
import com.bwie.pojo.Repais;
import com.bwie.service.RepaisService;
import com.bwie.service.impl.RepaisServiceImpl;
import com.bwie.utils.R;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.multipart.MultipartFile;

/**
* (t_repais)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/t_repais")
public class RepaisController {
/**
* 服务对象
*/
    @Autowired
    private RepaisService repaisServiceImpl;


    @ApiOperation("获取两周内每天的保修数")
    @PostMapping("/getWeekCount")
    public R getWeekCount(){
        return repaisServiceImpl.getWeekCount();
    }

    @ApiOperation("获取一年内，每个月的维修状态占比")
    @PostMapping("getYearData")
    public R getYearData(){
        return repaisServiceImpl.getYearData();
    }





    @ApiOperation("获取报修列表列表")
    @PostMapping("/getList")
    public R getList(@RequestBody Repais repais){
        return repaisServiceImpl.getList(repais);
    }



    @ApiOperation("获取报修类型")
    @PostMapping("getRepaisType")
    public R getRepaisType(){
        return repaisServiceImpl.getRepaisType();
    }


    @ApiOperation("添加报修")
    @PostMapping("addRepais")
    public R addRepais(@RequestBody @Validated Repais repais){
        return repaisServiceImpl.addRepais(repais);
    }


    @ApiOperation("获取区域数据")
    @PostMapping("getRepaisArea")
    public R getRepaisArea(){
        return repaisServiceImpl.getRepaisArea();
    }


    @ApiOperation("上传文件")
    @PostMapping("/uploadFile")
    public R uploadFile(@RequestPart("file")MultipartFile file){
        return repaisServiceImpl.uploadFile(file);
    }

    @ApiOperation("获取报修记录")
    @PostMapping("getRepaisRecord/{id}")
    public R getRepaisRecord(@PathVariable("id") Integer id){
        return repaisServiceImpl.getRepaisRecord(id);
    }
    @ApiOperation("修改报修记录")
    @PostMapping("updateRepais")
    public R updateRepais(@RequestBody Repais repais){
        return repaisServiceImpl.updateRepais(repais);
    }

    @PostMapping("getControlList")
    @ApiOperation("获取报修管理列表")
    public R getControlList(@RequestBody Repais repais){
        return repaisServiceImpl.getControlList(repais);
    }

    @ApiOperation("修改报修状态")
    @PostMapping("updateRespaisStatus")
    public  R updateRespaisStatus(@RequestBody Repais repais){
        return repaisServiceImpl.updateRespaisStatus(repais);
    }



}
